<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const [a, b, c, d] = [1, 2, 3]
        console.log(a, b, c, d) // 1 2 3 undefined

        let [foo] = []
        console.log(foo) // undefined

        let [aa, bb, ...cc] = ['abc']
        console.log(aa, bb, cc) // abc undefined []

        let [ee, ff] = [1, 2, 3]
        console.log(ee, ff) // 1 2

        let [gg, hh, ...jj] = [1, 2, 3, 4, 5, 6, 7]
        console.log(gg, hh, jj) // 1 2 [3, 4, 5, 6, 7]

        const [oo, pp, , ii] = [1, 2, 3, 4]
        console.log(oo, pp, ii) // 1 2 4

        // 默认值
        const [m = 0, n = 1] = [66, 77]
        console.log(m, n) // 66 77

        const [qq = 0, ww = 1] = [100]
        console.log(qq, ww) // 100 1

        const [zz = 0, xx = 1] = ['undefined', undefined]
        console.log(zz, xx) // 'undefined' 1

        // 右侧不是数组的时候 会报错
        //   let [kk] = 20
        //   console.log(kk)
        //   let [ss] = true
        //   let [vv] = {}
        //   let [ll] = undefined
        //   let [rr] = NaN
    </script>
</body>

</html>